import java.util.ArrayList;
import java.util.List;


public class Polynomial {
	Complex[] poly;
	List<Integer> alphalist;
	List<Complex> coeffs;
	
	Polynomial(){
		alphalist=new ArrayList<Integer>();
		coeffs=new ArrayList<Complex>();
	}
	
	public void addMonomial(Integer alpha,Complex comp){
		alphalist.add(alpha);
		coeffs.add(comp);
	}
	
	public Complex eval(int i,int N){
		Complex result=new Complex(0,0);
		Complex tempvar;
		for(int j=0;j<alphalist.size();j++){
			tempvar=(new Complex(0,i*alphalist.get(j)*2*Math.PI/N)).exp();
			result=result.plus(tempvar);
		}
		//System.out.println(result.imag()==(new Complex(0,2*Math.PI*2*i/N).exp().plus(new Complex(0,2*Math.PI*4*i/N).exp().times(new Complex(4,5)))).imag());
        return result;
//		return((new Complex(0,2*Math.PI*i*9/N)).exp().times(new Complex(0,1)));
	}
	
	@Override
	public String toString() {
		String output="";
		for(int i=0;i<coeffs.size();i++){
			output+=coeffs.get(i).toString();
			output+="*chi(" + alphalist.get(i) + ") ";
		}
		return output;
	}
	
}
